package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
@ToString
public class Customer {
    public static final int STATUS_COMMON = 0;//潜在客户
    public static final int STATUS_NORMAL = 1;//正式客户
    public static final int STATUS_FAIL = 2;//开发失败
    public static final int STATUS_LOST = 3;//流失客户
    public static final int STATUS_POOL = 4;//客户池

    private Long id;

    private String name;

    private Integer num;

    private Integer age;

    private Integer gender;

    private String tel;

    private String qq;

    private SystemDictionaryItem job;

    private SystemDictionaryItem source;

    private Employee seller;

    private Employee inputUser;

    private Date inputTime;

    private Integer status = STATUS_COMMON;

    public String getJson() {
        //封装数据更加安全
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("age", age);
        map.put("gender", gender);
        map.put("tel", tel);
        map.put("qq", qq);
        if (job != null) {
            map.put("jobId", job.getId());
        }
        if (source != null) {
            map.put("sourceId", source.getId());
        }
        if (seller != null) {
            map.put("seller", seller);
        }
        return JSON.toJSONString(map);
    }


    public String getStatusName() {
        switch (status) {
            case STATUS_COMMON:
                return "潜在客户";

            case STATUS_NORMAL:
                return "正式客户";
            case STATUS_FAIL:
                return "开发失败";
            case STATUS_LOST:
                return "流失客户";
            default:
                return "客户池";
        }
    }

}